/*
 * File:        UDP_Contents.h
 * Authors:     Jonathan Kotker (ee122-bw) and Shaan Mulchandani (ee122-bv)
 * Description: This header file contains a struct that describes
 *              the contents of a packet to be sent across by UDP.
 */

#include "constants.h"

#ifndef _UDP_CONTENTS_H
#define	_UDP_CONTENTS_H

typedef struct {

    /* Message type in all UDP packet types;
     * uses the 'messages' enum in "constants.h". */
    enum UDP_messages messageType;

    /* Player Name in STORAGE_LOCATION_REQUEST;
     * Player Name in PLAYER_STATE_REQUEST;
     * Player Name in PLAYER_STATE_RESPONSE;
     * Player Name in SAVE_STATE_RESPONSE. */
    char playerName[EE122_MAX_NAME_LENGTH + 1];

    /* ID in all UDP packet types. */
    unsigned long int id;

    /* Server IP address in STORAGE_LOCATION_RESPONSE;
     * Server IP address in SERVER_AREA_RESPONSE. */
    unsigned long int server_ip_add;

    /* Server UDP port in STORAGE_LOCATION_RESPONSE. */
    unsigned short int server_udp_port;

    /* Server TCP Port in SERVER_AREA_RESPONSE. */
    unsigned short int server_tcp_port;

    /* Minimum X in SERVER_AREA_RESPONSE. */
    char minX;

    /* Maximum X in SERVER_AREA_RESPONSE. */
    char maxX;

    /* Minimum Y in SERVER_AREA_RESPONSE. */
    char minY;

    /* Maximum Y in SERVER_AREA_RESPONSE. */
    char maxY;

    /* Error code in SAVE_STATE_RESPONSE. */
    char errorCode;

    /* HP in PLAYER_STATE_RESPONSE. */
    unsigned long int hp;

    /* EXP in PLAYER_STATE_RESPONSE. */
    unsigned long int exp;

    /* X in SERVER_AREA_REQUEST. */
    char xLoc;

    /* Y in SERVER_AREA_REQUEST. */
    char yLoc;

    /* Set to 1 if the corresponding packet is invalid. */
    char errorFlag;

} UDP_Contents;

#endif	/* _UDP_CONTENTS_H */
